﻿using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Options;
using SelfService.HaiTai.Models;
using SelfService.HaiTai.Models.HisOracle;
using SelfService.Model.Interface;

namespace SelfService.HaiTai
{
    public static class HaiTaiServiceExtension
    {
        public static void AddHaiTaiService(this IServiceCollection services, IConfiguration configRoot)
        {
            //注入配置文件
            services.Configure<AppSettings>(configRoot.GetSection("AppSettings"));
            var settings = services.BuildServiceProvider().GetRequiredService<IOptions<AppSettings>>().Value;
            //注入HIS缴费接口
            services.AddScoped<IHisOrder, HaiTaiOrder>();
            //注入HIS用户接口
            services.AddScoped<IHisUser, HaiTaiUser>();
            //注入挂号接口
            services.AddScoped<IAppointment, HaiTaiAppointment>();
            //注入HIS数据库
            services.AddDbContext<HisContext>(options =>
            {
                options.UseOracle(settings.HisOracleConnection);
            });
            //注入发票打印接口
            services.AddScoped<IReceiptPrint, HaiTaiReceiptPrint>();
            //注入医保缴费接口
            services.AddScoped<ISocialSecurityOrder, HaiTaiSocialSecurityOrder>();
        }
    }
}
